package com.JobFind.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

import com.JobFind.DTO.LogDTO;


/**
 * TbLog entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="tb_log",catalog="jobfind")
@Proxy(lazy = false)
public class TbLog  implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer logId;
    private TbUser tbUser;
    private String logIp;
    private String logTime;


    // Constructors

    /** default constructor */
    public TbLog() {
    }

    
    /** full constructor */
    public TbLog(TbUser tbUser, String logIp, String logTime) {
        this.tbUser = tbUser;
        this.logIp = logIp;
        this.logTime = logTime;
    }

   
    // Property accessors
    @Id @GeneratedValue
    
    @Column(name="LogId", unique=true, nullable=false)

    public Integer getLogId() {
        return this.logId;
    }
    
    public void setLogId(Integer logId) {
        this.logId = logId;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="UserId")

    public TbUser getTbUser() {
        return this.tbUser;
    }
    
    public void setTbUser(TbUser tbUser) {
        this.tbUser = tbUser;
    }
    
    @Column(name="LogIp", length=30)

    public String getLogIp() {
        return this.logIp;
    }
    
    public void setLogIp(String logIp) {
        this.logIp = logIp;
    }
    
    @Column(name="LogTime", length=30)

    public String getLogTime() {
        return this.logTime;
    }
    
    public void setLogTime(String logTime) {
        this.logTime = logTime;
    }
   
    public LogDTO toDTO(){
    	LogDTO logDTO = new LogDTO();
    	logDTO.setLogId(this.getLogId());
    	logDTO.setLogIp(this.getLogIp());
    	logDTO.setLogTime(this.getLogTime());
    	logDTO.setUserDTO(this.getTbUser().toDTO());
    	return logDTO;
    }
}